package com.cyl.XmlDemo.web;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.messaging.simp.annotation.SubscribeMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.cyl.XmlDemo.entity.Shout;
import com.cyl.XmlDemo.service.MarcoService;

//@Controller
//@RequestMapping(value="/")
public class IndexController {
	
	private Logger log = LoggerFactory.getLogger(IndexController.class);
	
	@Autowired
	private MarcoService marcoService;
	
	@RequestMapping(value={"index"},method=RequestMethod.GET)
	public String index(){
		log.error("index 被调用");
		System.out.println("index 被调用");
		return "index";
	}
	
	@RequestMapping(value="home",method=RequestMethod.GET)
	public String home(){
		System.out.println("home 被调用");
		return "home";
	}
	
	@RequestMapping(value="ws",method=RequestMethod.GET)
	public String ws(){
		return "websocket";
	}
	
	@RequestMapping(value="sockjs",method=RequestMethod.GET)
	public String sockjs(){
		return "sockjs";
	}
	
	@RequestMapping(value="stomp",method=RequestMethod.GET)
	public String stomp(){
		return "stomp";
	}
	
	@RequestMapping(value="stompsub",method=RequestMethod.GET)
	public String stomp_subscribe(){
		return "stomp-subscribe";
	}
	
	@RequestMapping(value="stompserver",method=RequestMethod.GET)
	public String stomp_server(){
		return "stomp-server";
	}
	
	@RequestMapping(value="stompss",method=RequestMethod.GET)
	public String stomp_ss(){
		return "stomp-ss";
	}
	
	@RequestMapping(value="stompuser",method=RequestMethod.GET)
	public String user(){
		return "stomp-user";
	}
	
	@RequestMapping(value="stompall",method=RequestMethod.GET)
	public String alluser(){
		return "stomp-all";
	}
	
	@RequestMapping(value="ms",method=RequestMethod.GET)
	public void mMethod(){
		log.debug("开始调用 Marco Service");
		Shout shout = new Shout();
		shout.setMessage("服务器端 发送信息给 Polo!");
		marcoService.sendMsg(shout);
	}
	
	/**
	 * 同一网页内部
	 */
	@RequestMapping(value="innerHtml",method=RequestMethod.GET)
	public String innerHtml(){
		return "inner-html";
	}
	
	//同一个浏览器
	@RequestMapping(value={"","innerBrowser"},method=RequestMethod.GET)
	public String innerBrowser(){
		return "inner-browser";
	}
}
